<template>
  <div class="nav-header">
    <div class="menu-icon" @click="handleFoldClick">
      <el-icon size="22px">
        <component :is="isFold ? 'Expand' : 'Fold'" />
      </el-icon>
    </div>
    <div class="content">
      <header-crumb />
      <header-info />
    </div>
  </div>
</template>

<script setup lang="ts">
// 模块引入
import { ref } from 'vue'
import HeaderInfo from './header-info.vue'
import HeaderCrumb from './header-crumb.vue'
defineOptions({
  // 组件名称
  name: 'MainHeader',
  // 继承透传，是否继承没在子组件声明的父组件的属性
  inheritAttrs: true
})
// 0、自定义事件
const emit = defineEmits(['foldChange'])
// 1、记录状态
const isFold = ref<boolean>(false)

function handleFoldClick() {
  isFold.value = !isFold.value
  // 通知父组件
  emit('foldChange', isFold.value)
}
</script>

<style scoped lang="scss">
.nav-header {
  // padding: 0 20px;
  display: flex;
  align-items: center;
  flex: 1;
  height: 100%;
  .menu-icon {
    display: flex;
    align-items: center;
    cursor: pointer;
  }
  .content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    padding: 0 18px;
  }
}
</style>
